package com.c.elmer.util.file;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;

public class MyFile {
	public static void main(String[] args) {
		new MyFile().saveFile("e:/mainSaveT.txt", "wzj_1234");
	}
	public boolean saveFile(String path,String content){
		boolean issave = false;
		try{
			File file = new File(path);
			
			file.createNewFile();
			
			FileOutputStream fo = new FileOutputStream(
					new File(path)
			);
			fo.write(content.getBytes());
			fo.close();
			
			issave = true;
		}catch (Exception e) {
			e.printStackTrace();
		}
		
		return issave;
	}
	
	public boolean saveFile(String path,InputStream in){
		boolean issave = false;
		try{
			File file = new File(path);
			
			file.createNewFile();
			
			FileOutputStream   fos   =   new   FileOutputStream(
					new File(path)
			); 
			
			byte[] buff = new byte[1024]; 
			int readed = -1; 
			
			while((readed = in.read(buff)) >   0){				
				fos.write(buff,0,readed); 
			}
			fos.close();
			
			issave = true;
		}catch (Exception e) {
			e.printStackTrace();
		}
		
		return issave;
	}

}
